package com.example.localareanetworkchat.persistence.dao

import androidx.lifecycle.LiveData
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import com.example.localareanetworkchat.persistence.entity.ChatGroupUser

@Dao
interface ChatGroupUserDao {

    @Insert
    fun insert(chatGroupUser: ChatGroupUser)

    @Insert
    fun insertAll(chatGroupUser: List<ChatGroupUser>)

    @Query("select * from chat_group_user where chat_group_id = :chatGroupId")
    fun queryByChatGroupId(chatGroupId: String): LiveData<List<ChatGroupUser>>

    @Query("select * from chat_group_user where chat_group_id = :chatGroupId")
    fun queryByChatGroupIdAtNow(chatGroupId: String): List<ChatGroupUser>

    @Query("select * from chat_group_user where uid = :uid and chat_group_id = :chatGroupId")
    fun queryByUidAndChatGroupId(uid: String, chatGroupId: String): ChatGroupUser

    @Query("delete from chat_group_user where uid = :uid and chat_group_id = :chatGroupId")
    fun deleteByUidAndChatGroupId(uid: String, chatGroupId: String)

}